﻿Imports System.ComponentModel
Imports System.Collections.ObjectModel

Public Class OrderControlViewModel
    Implements INotifyPropertyChanged

    Private _auftrag As FuncClasses.Order
    Private _linkedOrders As ObservableCollection(Of FuncClasses.OrderPreviewModel)

    Public Sub New(ByRef auftrag As FuncClasses.Order)
        _auftrag = auftrag
        _linkedOrders = New ObservableCollection(Of FuncClasses.OrderPreviewModel)
    End Sub

    Protected Sub NotifyPropertyChanged(info As [String])
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

    Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
#Region "Privates"

#End Region

#Region "Properties"
    Public Property Order As FuncClasses.Order
        Get
            Return _auftrag
        End Get
        Set(value As FuncClasses.Order)
            _auftrag = value
            NotifyPropertyChanged("")
        End Set
    End Property

    Public ReadOnly Property LinkedOrders As ObservableCollection(Of FuncClasses.OrderPreviewModel)
        Get
            Return _linkedOrders
        End Get
    End Property
#Region "Delivery Address"
    Public Property DeliverySalutation As String
        Get
            Try
                Return Order.DeliveryAddress.Salutation
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Salutation = value
            NotifyPropertyChanged("DeliverySalutation")
        End Set
    End Property

    Public Property DeliveryForname As String
        Get
            Try
                Return Order.DeliveryAddress.Forname
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Forname = value
            NotifyPropertyChanged("DeliveryForname")
        End Set
    End Property

    Public Property DeliverySurname As String
        Get
            Try
                Return Order.DeliveryAddress.Surname
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Surname = value
            NotifyPropertyChanged("DeliverySurname")
        End Set
    End Property

    Public Property DeliveryStreet As String
        Get
            Try
                Return Order.DeliveryAddress.Street
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Street = value
            NotifyPropertyChanged("DeliveryStreet")
        End Set
    End Property

    Public Property DeliveryNo As String
        Get
            Try
                Return Order.DeliveryAddress.No
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.No = value
            NotifyPropertyChanged("DeliveryNo")
        End Set
    End Property

    Public Property DeliveryZip As String
        Get
            Try
                Return Order.DeliveryAddress.ZipCode
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.ZipCode = value
            NotifyPropertyChanged("DeliveryZip")
        End Set
    End Property

    Public Property DeliveryCity As String
        Get
            Try
                Return Order.DeliveryAddress.City
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.City = value
            NotifyPropertyChanged("DeliveryCity")
        End Set
    End Property

    Public Property DeliveryCountry As String
        Get
            Try
                Return Order.DeliveryAddress.Country
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Country = value
            NotifyPropertyChanged("DeliveryCountry")
        End Set
    End Property

    Public Property DeliveryAddition As String
        Get
            Try
                Return Order.DeliveryAddress.Addition
            Catch ex As Exception
                Return Nothing
            End Try
        End Get
        Set(value As String)
            Order.DeliveryAddress.Addition = value
            NotifyPropertyChanged("DeliveryAddition")
        End Set
    End Property
#End Region

    Public Sub UIRefresh()
        NotifyPropertyChanged("")
    End Sub
#End Region
End Class
